package mappers;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import domains.Login;
import managers.DatabaseConnection;

public class LoginMapper {
	
	public boolean checkLogin(Login l) {
		String sql = "SELECT * FROM hovedopgave.login where login_username = ? AND login_password = ?";
		try {
		DatabaseConnection dbConnect = new DatabaseConnection();

		PreparedStatement query = dbConnect.getConnect().prepareStatement(sql);
		query.setString(1, l.getUsername());
		query.setString(2, l.getPassword());
		ResultSet rs = query.executeQuery();
		
		if (rs.next()) {
			return true;
			
		} 
		dbConnect.getConnect().close();

		} catch(Exception e) {
			e.printStackTrace();
		}
		
		return false;
	}
}
